import React, { Component } from 'react';
import '../styles/Goods.scss'

import * as service from '../api/index'

class Goods extends Component {
    constructor(props) {
        super(props)
        this.state = {
            list: []
        }
    }
    async componentDidMount(){
        var res = await service.index_goodlist()
        this.setState({list:res.data.list})
    }
    render() {
        return (
            <div className="goods">
                {
                    this.state.list.map((item, index) => {
                        return (
                            <div className="item" key={index}>
                                <img src={item.pic} alt="" />
                                <div className="name">{item.name}</div>

                                <div className="discount">{item.salesPrice.name}￥<span>{item.salesPrice.value}</span></div>
                            </div>
                        )
                    })
                }
            </div>
        );
    }
}

export default Goods;